package com.zenithmind.chat.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import java.util.List;

/**
 * AI对话更新DTO
 * 遵循单一职责原则，专门用于更新对话
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "AI对话更新DTO")
public class AiChatUpdateDTO extends BaseDTO {
    
    @NotBlank(message = "对话ID不能为空")
    @Schema(description = "对话ID", required = true)
    private String chatId;
    
    @Size(max = 100, message = "对话标题长度不能超过100个字符")
    @Schema(description = "对话标题")
    private String title;
    
    @Size(max = 2000, message = "系统提示词长度不能超过2000个字符")
    @Schema(description = "系统提示词")
    private String systemPrompt;
    
    @Schema(description = "状态(0-禁用,1-启用)")
    private Integer status;
    
    @Schema(description = "标签列表")
    private List<String> tags;
    
    @Schema(description = "共享类型(0-私有,1-公开,2-指定用户)")
    private Integer shareType;
    
    @Schema(description = "共享用户ID列表")
    private List<String> shareUserIds;
    
    @Override
    public boolean isValid() {
        // 验证状态值
        if (status != null && (status < 0 || status > 1)) {
            return false;
        }
        
        // 验证共享类型
        if (shareType != null && (shareType < 0 || shareType > 2)) {
            return false;
        }
        
        // 如果是指定用户共享，必须提供用户ID列表
        if (Integer.valueOf(2).equals(shareType) && 
            (shareUserIds == null || shareUserIds.isEmpty())) {
            return false;
        }
        
        return super.isValid();
    }
    
    @Override
    public String getBusinessKey() {
        return chatId;
    }
}
